﻿using System.Collections.Generic;
using System.ComponentModel;
using G.Model;

namespace G.Model.Converters
{
    public class GlobalValueDefConverter : StringConverter
    {
        public static List<string> GetCommands(GameSpaceDef pGame)
        {
            List<string> result = new List<string>();
            foreach (GameValueDef t in pGame.GlobalDef.GameValueDefs)
            {
                result.Add(t.Name);
            }

            return result;
        }

        public override bool GetStandardValuesSupported(
                                   ITypeDescriptorContext context)
        {
            return true;
        }

        public override StandardValuesCollection
                             GetStandardValues(ITypeDescriptorContext context)
        {
            object obj = context.Instance;
            HasGameSpaceDef dispatcher = (HasGameSpaceDef)obj;
            List<string> list = GetCommands(dispatcher.GameDef);
            return new StandardValuesCollection(list);
        }

        public override bool GetStandardValuesExclusive(
                                   ITypeDescriptorContext context)
        {
            return false;
        }

    }
}
